<?php
namespace Admin\Controller;
use Admin\Controller;

class IndexController extends BaseController{

    public function index(){
        
        $this->assign('time', date("Y-m-d H:i:s", time()));
		$this->assign('sys1', php_uname());
		$this->assign('client_ip',  $_SERVER['REMOTE_ADDR']);
		$this->assign('software', $_SERVER['SERVER_SOFTWARE']);
		$this->assign('root', str_replace('\\','/',realpath(dirname(__FILE__).'/'))."/");
		$this->assign('version', PHP_VERSION);
		$this->assign('language',  $_SERVER['HTTP_ACCEPT_LANGUAGE']);
		$this->assign('port',  $_SERVER['SERVER_PORT']);
        $this->display();
    }
    
    public function clear_cache(){
        $dirs = array(dirname(dirname(dirname(__FILE__))).'./Runtime/');
        @mkdir('Runtime',0777,true);
        //清理缓存
        foreach($dirs as $value) {
           $this->rmdirr($value);
        }
        echo 1;
    }
    
    public function rmdirr($dirname) {
      if (!file_exists($dirname)) {
       return false;
      }
      if (is_file($dirname) || is_link($dirname)) {
       return unlink($dirname);
      }
      $dir = dir($dirname);
      if($dir){
       while (false !== $entry = $dir->read()) {
        if ($entry == '.' || $entry == '..') {
         continue;
        }
        //递归
        $this->rmdirr($dirname . DIRECTORY_SEPARATOR . $entry);
       }
      }
      $dir->close();
      return rmdir($dirname);
    }
}
